﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text.RegularExpressions;
using System.Web;
using System.Web.Mvc;
using System.Web.SessionState;
using System.Web.UI.WebControls;
using GWEB.WebBase.Data;
using GWEB.WebBase.Entity;
using GWEB.WebBase.Utility;
using GWEB.WebFrame.Public;
using Newtonsoft.Json;

namespace GWEB.WebFrame.CReportform
{
    public class ContractFormController : PageInfoBase
    {
        [ActionFilter(IsLogin = false)]
        public ActionResult Index(String id, String keyCode)
        {
            ViewBag.Id = id;
            ViewBag.KeyCode = keyCode;
            return View(BasePage.V("CReportform/ContractForm"));
        }
        public JsonResult DataList(String id, String keyCode)
        {
            if (!Fun.IDVerify(id, keyCode))
                return BasePage.Json(ResultData.Code("0001", "您没有权限"));

            BaseData bd = new BaseData();
            string UserId = BasePage.GetUserId(Session);
            String sql = "select cu_Course_class where id={0}";
            bool t = bd.ExecuteSQL(string.Format(sql, id));
            if (t)
                return BasePage.Json(ResultData.Code("0000", WebMessage.SaveSuccess));
            else
                return BasePage.Json(ResultData.Code("0001", WebMessage.SaveFailure));
        }

        public JsonResult DelCourse(String id, String keyCode)
        {
            if (!Fun.IDVerify(id, keyCode))
                return BasePage.Json(ResultData.Code("0001", "您没有权限"));

            BaseData bd = new BaseData();
            string UserId = BasePage.GetUserId(Session);
            String sql = "delete cu_Course_class where id={0}";
            bool t = bd.ExecuteSQL(string.Format(sql, id));
            if (t)
                return BasePage.Json(ResultData.Code("0000", WebMessage.SaveSuccess));
            else
                return BasePage.Json(ResultData.Code("0001", WebMessage.SaveFailure));
        }

        protected override void FieldAddInit(DataRow data)
        {
            data["CeateId"] = BasePage.GetUserId(Session);
            DataRow drUser = BasePage.GetUser(Session);
            data["LeagueId"] = Fun.cString(drUser["LeagueId"].ToString());
            ViewBag.Lx = 0;
            data["State"] = 1;
            data["CeateDate"] = DateTime.Now.ToString();
            base.FieldAddInit(data);
        }
        protected override void FieldEditInit(DataRow data)
        {
            ViewBag.Lx = 1;
            base.FieldEditInit(data);
        }

    }
}